class CreateCategories < ActiveRecord::Migration[5.1]
  def change
    create_table :categories, comment: '产品分类' do |t|
      t.string :name, comment: '产品名称'
      t.string :alias, comment: '别名'

      t.integer :parent_id, :null => true, :index => true, comment: '父级id'
      t.integer :lft, :null => false, :index => true, comment: '左边的id'
      t.integer :rgt, :null => false, :index => true, comment: '右边的id'

      # optional fields
      t.integer :depth, :null => false, :default => 0, comment: '深度'
      t.integer :children_count, :null => false, :default => 0, comment: '子级数量'

      t.timestamps
    end
  end
end
